﻿namespace ChinaUnicom.Models
{
    using System;
    using System.ComponentModel;

    public class Package : INotifyPropertyChanged
    {
        public Package()
        {
            Occurred = DateTime.Now;
            Started = DateTime.Now;
            Ended = DateTime.Now;
            Items = new ItemCollection();
        }

        DateTime occurred;
        public DateTime Occurred
        {
            get { return occurred; }
            set
            {
                if (occurred != value)
                {
                    occurred = value;
                    NotifyPropertyChanged("Occurred");
                }
            }
        }

        DateTime started;
        public DateTime Started
        {
            get { return started; }
            set
            {
                if (started != value)
                {
                    started = value;
                    NotifyPropertyChanged("Started");
                }
            }
        }

        DateTime ended;
        public DateTime Ended
        {
            get { return ended; }
            set
            {
                if (ended != value)
                {
                    ended = value;
                    NotifyPropertyChanged("Ended");
                }
            }
        }

        string name;
        public string Name
        {
            get { return name; }
            set
            {
                if (name != value)
                {
                    name = value;
                    NotifyPropertyChanged("Name");
                }
            }
        }

        ItemCollection items;
        public ItemCollection Items
        {
            get { return items; }
            set
            {
                if (items != value)
                {
                    items = value;
                    NotifyPropertyChanged("Items");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
